<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body onload=main()>
    <canvas id='webgl' width="400" height='400'>如果你看见我，就请更换别的浏览器查看效果</canvas>
    <script src='lib/webgl-utils.js'></script>
    <script src='lib/webgl-debug.js'></script>
    <script src='lib/cuon-utils.js'></script>
    <script>
        function main(){
            let canvas=document.getElementById('webgl');
            let gl=getWebGLContext(canvas);
            if(!gl){
                console.log(获取元素错误);
                return false
            }
            gl.clearColor(0.0,0.5,0.8,1.0);
            gl.clear(gl.COLOR_BUFFER_BIT);
        }
    
    
    </script>

    <button id='parent'>我是按钮1</button>

    <iframe  id='test' width='400' height='400'></iframe>
    <script type="text/javascript">
        let test=document.getElementById('test');
        let parent=document.getElementById('parent');

        parent.onclick=function(){
            test.src='http://localhost:8081/er-wei-ma.html'  
         test.contentWindow.postMessage('hiahiahia','http://localhost:8081') 

        }
        /*test.onload=function(){
            alert(123);
           test.src='http://localhost:8081/er-wei-ma.html'  
         test.contentWindow.postMessage('hahaha','http://localhost:8081')   
        }*/

        window.addEventListener("message",function(event){console.log(event)}, false);
        
    </script>


</body>
</html>